<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- page specific plugin scripts -->

<!--[if lte IE 8]>
  <script src="${acePath}/assets/js/excanvas.min.js"></script>
<![endif]-->
<script src="${acePath}/assets/js/jquery-ui.custom.min.js"></script>
<script src="${acePath}/assets/js/jquery.ui.touch-punch.min.js"></script>
<!-- ace scripts -->
<script src="${acePath}/assets/js/ace-elements.min.js"></script>
<script src="${acePath}/assets/js/ace.min.js"></script>
<script type="text/javascript">
function setSkin(b){
	
	var a=$(document.body);
	a.attr("class",a.hasClass("navbar-fixed")?"navbar-fixed":"");
	if(b!="default"){
		a.addClass(b);
	}if(b=="skin-1"){
		$(".ace-nav > li.grey").addClass("dark");
	}else{
		$(".ace-nav > li.grey").removeClass("dark");
	}
	if(b=="skin-2"){
			$(".ace-nav > li").addClass("no-border margin-1");
			$(".ace-nav > li:not(:last-child)").addClass("white-pink")
			.find('> a > [class*="icon-"]').addClass("pink").end()
			.eq(0).find(".badge").addClass("badge-warning");
	}else{
			$(".ace-nav > li").removeClass("no-border").removeClass("margin-1");
			$(".ace-nav > li:not(:last-child)").removeClass("white-pink")
			.find('> a > [class*="icon-"]').removeClass("pink").end()
			.eq(0).find(".badge").removeClass("badge-warning");
	}
	if(b=="skin-3"){
		$(".ace-nav > li.grey").addClass("red").find(".badge").addClass("badge-yellow");
	}else{
		$(".ace-nav > li.grey").removeClass("red").find(".badge").removeClass("badge-yellow");
	}
}

jQuery(function($) {
	$(document).on('settings.ace', function(ev, event_name, event_val, event_source, save_state) {
		var checkbox = '';
		switch(event_name) {
			case 'navbar_fixed':
				checkbox = 'ace-settings-navbar';
			break;
			
			case 'sidebar_fixed':
				checkbox = 'ace-settings-sidebar';
			break;
			
			case 'breadcrumbs_fixed':
				checkbox = 'ace-settings-breadcrumbs';
			break;
			
			case 'main_container_fixed':
				checkbox = 'ace-settings-add-container';
			break; 
		}
		
		if( checkbox && (checkbox = document.getElementById(checkbox)) ) {
			$(checkbox).prop('checked', event_val);

			try {
				if(save_state == true) ace.settings.saveState(checkbox, 'checked');
			} catch(e) {}
		}
	 });
	$('#ace-settings-switch-menu').on('click', function(){
		if(this.checked) {
			if($('#sidebar').hasClass('h-sidebar')) return;
			$('#sidebar li').addClass('hover')
			.filter('.open').removeClass('open').find('> .submenu').css('display', 'none');
			//and remove .open items
			var $sidebar = $('#sidebar');
		    $sidebar.addClass("navbar-collapse h-sidebar");
		}
		else {
			$('#sidebar li.hover').removeClass('hover');
			$('#sidebar').removeClass('navbar-collapse').removeClass('h-sidebar').addClass("sidebar");

			var compact = $('#ace-settings-compact');
			if( compact.length > 0 && compact.get(0).checked ) {
				compact.trigger('click');
			}
		}
	 })
	/////////////////////////////////////
	$(document).one('ajaxloadstart.page', function(e) {
		$tooltip.remove();
	});


	$('.dialogs,.comments').ace_scroll({
		size: 300
    });
	
	
	//Android's default browser somehow is confused when tapping on label which will lead to dragging the task
	//so disable dragging when clicking on label
	var agent = navigator.userAgent.toLowerCase();
	if("ontouchstart" in document && /applewebkit/.test(agent) && /android/.test(agent))
	  $('#tasks').on('touchstart', function(e){
		var li = $(e.target).closest('#tasks li');
		if(li.length == 0)return;
		var label = li.find('label.inline').get(0);
		if(label == e.target || $.contains(label, e.target)) e.stopImmediatePropagation() ;
	});

	$('#tasks').sortable({
		opacity:0.8,
		revert:true,
		forceHelperSize:true,
		placeholder: 'draggable-placeholder',
		forcePlaceholderSize:true,
		tolerance:'pointer',
		stop: function( event, ui ) {
			//just for Chrome!!!! so that dropdowns on items don't appear below other items after being moved
			$(ui.item).css('z-index', 'auto');
		}
		}
	);
	$('#tasks').disableSelection();
	$('#tasks input:checkbox').removeAttr('checked').on('click', function(){
		if(this.checked) $(this).closest('li').addClass('selected');
		else $(this).closest('li').removeClass('selected');
	});


	//show the dropdowns on top or bottom depending on window height and menu position
	$('#task-tab .dropdown-hover').on('mouseenter', function(e) {
		var offset = $(this).offset();

		var $w = $(window)
		if (offset.top > $w.scrollTop() + $w.innerHeight() - 100) 
			$(this).addClass('dropup');
		else $(this).removeClass('dropup');
	});

})
</script>
<script type="text/javascript">
jQuery(function($) {
	//菜单显示方式：
	//var $sidebar = $('.sidebar').eq(0);
	 //if( !$sidebar.hasClass('h-sidebar') ) 
		// $sidebar.addClass("navbar-collapse h-sidebar");
});
</script>
<!-- inline scripts related to this page -->
<script type="text/javascript">
	jQuery(function($) {
	 var $sidebar = $('.sidebar').eq(0);
	 if( !$sidebar.hasClass('h-sidebar') ) return;
	
	 $(document).on('settings.ace.top_menu' , function(ev, event_name, fixed) {
		if( event_name !== 'sidebar_fixed' ) return;
	
		var sidebar = $sidebar.get(0);
		var $window = $(window);
	
		//return if sidebar is not fixed or in mobile view mode
		var sidebar_vars = $sidebar.ace_sidebar('vars');
		if( !fixed || ( sidebar_vars['mobile_view'] || sidebar_vars['collapsible'] ) ) {
			$sidebar.removeClass('lower-highlight');
			//restore original, default marginTop
			sidebar.style.marginTop = '';
	
			$window.off('scroll.ace.top_menu')
			return;
		}
	
	
		 var done = false;
		 $window.on('scroll.ace.top_menu', function(e) {
	
			var scroll = $window.scrollTop();
			scroll = parseInt(scroll / 4);//move the menu up 1px for every 4px of document scrolling
			if (scroll > 17) scroll = 17;
	
	
			if (scroll > 16) {			
				if(!done) {
					$sidebar.addClass('lower-highlight');
					done = true;
				}
			}
			else {
				if(done) {
					$sidebar.removeClass('lower-highlight');
					done = false;
				}
			}
	
			sidebar.style['marginTop'] = (17-scroll)+'px';
		 }).triggerHandler('scroll.ace.top_menu');
	
	 }).triggerHandler('settings.ace.top_menu', ['sidebar_fixed' , $sidebar.hasClass('sidebar-fixed')]);
	
	 $(window).on('resize.ace.top_menu', function() {
		$(document).triggerHandler('settings.ace.top_menu', ['sidebar_fixed' , $sidebar.hasClass('sidebar-fixed')]);
	 });
	
	
	});
</script>